using System;
using HCP.Responses;
using HCP.SimpleJSON;
using UnityEngine;
using UnityEngine.UI;

namespace HCP.Requests
{
	public class SetElementText : JobRequest
	{
		public SetElementText(JSONClass json) : base(json)
		{
		}

		public string Id
		{
			get
			{
				return base.Data["elementId"];
			}
		}

		public string Text
		{
			get
			{
				return base.Data["text"];
			}
		}

		public bool Replace
		{
			get
			{
				return base.Data["replace"].AsBool;
			}
		}

		public bool Unicode
		{
			get
			{
				return base.Data["unicodeKeyboard"].AsBool;
			}
		}

		public override JobResponse Process()
		{
			Component elementById = JobRequest.GetElementById(this.Id);
			Text component = elementById.GetComponent<Text>();
			InputField component2 = elementById.GetComponent<InputField>();
			if (this.Replace)
			{
				if (component != null)
				{
					component.text = this.Text;
				}
				else
				{
					component2.text = this.Text;
				}
			}
			else if (component != null)
			{
				Text text = component;
				text.text += this.Text;
			}
			else
			{
				InputField inputField = component2;
				inputField.text += this.Text;
			}
			return new StringResponse();
		}
	}
}
